<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Class	: C_msthscode
 * 
 * Table	: msthscode
 *  
 * @author Eko Junaidi Salam
 *
 */
class C_msthscode extends CI_Controller {
 
	function __construct(){
		parent::__construct();		
		$this->load->model('m_msthscode', '', TRUE);
	}
	
	function getAll(){
		/*
		 * Collect Data
		 */
		$start  =   ($this->input->post('start', TRUE) ? $this->input->post('start', TRUE) : 0);
		$page   =   ($this->input->post('page', TRUE) ? $this->input->post('page', TRUE) : 1);
		$limit  =   ($this->input->post('limit', TRUE) ? $this->input->post('limit', TRUE) : 15);
		
		/*
		 * Processing Data
		 */
		$result = $this->m_msthscode->getAll($start, $page, $limit);
		echo json_encode($result);
	}
	
	function save(){
		/*
		 * Collect Data ==> diambil dari [model.msthscode]
		 */
		$data   = json_decode($this->input->post('data',TRUE));
		
		/*
		 * Processing Data
		 */
		$result = $this->m_msthscode->save($data);
		echo json_encode($result);
	}
	
	function delete(){
		/*
		 * Collect Data ==> diambil dari [model.msthscode]
		 */
		$data   = json_decode($this->input->post('data',TRUE));
		
		/*
		 * Processing Data
		 */
		$result = $this->m_msthscode->delete($data);
		echo json_encode($result);
	}
	
	function printRecords(){
		$getdata = json_decode($this->input->post('data',TRUE));
		$data["records"] = $getdata;
		$data["table"] = "msthscode";
		$print_view=$this->load->view("p_msthscode.php",$data,TRUE);
		if(!file_exists("temp")){
			mkdir("temp");
		}
		$print_file=fopen("temp/msthscode.html","w+");
		fwrite($print_file, $print_view);
		echo '1';
	}	
}